using System.IO;
using Framework.Core.Recorder;
using Xunit;

namespace Framework.Tests.Core.Recorder.AcceptanceTests
{
    public class AutoPropertyTest
    {
        [Fact]
        public void Should_mock_autoproperty_for_all_implementation()
        {
            Should_test_property_behavior(new StateFullHardMock());
            Should_test_property_behavior(new HardMock());
        }

        private static void Should_test_property_behavior(IHardMock stateFullHardMock)
        {
            var recorder = stateFullHardMock.BuildRecorderOver<_MUODate>(new MUODate());

            MockUsingAutoProperty(recorder);

            using (var stream = new MemoryStream())
            {
                recorder.Snapshot(stream);
                var replayer = stateFullHardMock.BuildMockFrom<_MUODate>(stream);

                MockUsingAutoProperty(replayer);
            }
        }

        private static void MockUsingAutoProperty(_MUODate recorder)
        {
            recorder.AutoProperty = "toto";

            Assert.Equal("toto", recorder.AutoProperty);

            recorder.AutoProperty = "tutu";

            Assert.Equal("tutu", recorder.AutoProperty);
        }
    }
}